﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace intelliEssayBugCheckSystem
{
    public class ApplicationStates
    {
        public static ConnectionStates conState
        {
            get
            {
                Monitor.Enter(locked);
                ConnectionStates cs = _conState;
                Monitor.Exit(locked);
                return cs;
            }
            set
            {
                Monitor.Enter(locked);
                _conState = value;
                Monitor.Exit(locked);
            }
        }
        private static object locked = new object();
        private static ConnectionStates _conState;
        public static int CurrentUserID;
        public static string CurrentUserName;
        public static string GetUserNameFromAllHints()
        {
            string LoggedName = System.Environment.UserName.Replace(" ", "").ToLowerInvariant();
            if(LoggedName.Contains("kingwolf") || LoggedName.Contains("lisnb") || LoggedName.Contains("lxp")) return "李希鹏";
            if(LoggedName.Contains("wc") || LoggedName.Contains("llmainland") ) return "罗量";
            if (LoggedName.Contains("古剑寒") || LoggedName.Contains("gjh")) return "镇明敏";
            if(LoggedName.Contains("xiaoyuan") || LoggedName.Contains("宋") || LoggedName.Contains("sxy")) return "宋小远";
            return "Unknown";
         
        }
        public static int GetUserIDFromUserName(string id)
        {
            if (CurrentUserName == "罗量") return 3;
            if (CurrentUserName == "李希鹏") return 1;
            if (CurrentUserName == "宋小远") return 2;
            if (CurrentUserName == "镇明敏") return 4;
            else return 0;
        }
        private static object IOLock = new object();
        public static void LockIO()
        {
            Monitor.Enter(IOLock);
        }
        public static void ReleaseIO()
        {
            Monitor.Exit(IOLock);
        }
    }
    public enum ConnectionStates
    {
        Connected,
        Disconnected,
        Syncing
    }
}
